package com.zyl.Ecs.common.domain.device.ext;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zyl.Ecs.common.domain.device.bean.Sensor;
import com.zyl.Ecs.common.domain.device.vo.SensorVO;
import com.zyl.Ecs.common.utils.CUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.device.domain.ext
 * @ClassName: Sensor
 * @Description TODO (传感器扩展)
 * @Author 翟玉龙
 * @Date 2024/12/5-9:33
 */
@Data
@SuperBuilder
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(value = "ecs_sensor")
public class SensorExt extends Sensor {

    @TableField(exist = false)
    private SensorTypeExt sensorType;
    /**
     * 所属点位（出参）
     */
    @TableField(exist = false)
    private PositionExt position;

    public static SensorExt toExt(Sensor sensor) {
        return CUtil.copyBean(sensor, SensorExt.class);
    }

    public static SensorExt toExt(SensorVO sensorVO) {
        return SensorExt.builder()
                .id(sensorVO.getId())
                .name(sensorVO.getName())
                .positionId(sensorVO.getPositionId())
                .build();
    }
}
